//
//  AYMCircleScrollView.m
//  QuickCure
//
//  Created by xuNick on 16/5/5.
//  Copyright © 2016年 ayumi. All rights reserved.
//

#import "AYMCircleScrollView.h"

@interface AYMCircleScrollView ()

@property (nonatomic,strong) NSArray *imageViews;

@end


@implementation AYMCircleScrollView

-(instancetype)initWithFrame:(CGRect)frame animationDuration:(NSTimeInterval)animationDuration{
    if (self = [super initWithFrame:frame animationDuration:animationDuration]) {
        [self setupUI];
    }
    return self;
}

-(void)setupUI{
    NSArray *imageUrls = @[@"http://7xsiiq.com2.z0.glb.clouddn.com/h1.png",
                           @"http://7xsiiq.com2.z0.glb.clouddn.com/h2.png",
                           @"http://7xsiiq.com2.z0.glb.clouddn.com/h3.png"
                           ];
    NSMutableArray *imageViews = [NSMutableArray array];
    //循环添加views
    for (int i = 0; i < imageUrls.count; i++) {
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
        [imageView sd_setImageWithURL:[NSURL URLWithString:imageUrls[i]] placeholderImage:[UIImage imageNamed:@"good_image_default"] options:SDWebImageRetryFailed];
        [imageViews addObject:imageView];
    }
    self.imageViews = imageViews.copy;
    
    self.scrollView.showsHorizontalScrollIndicator = NO;
    self.backgroundColor = [UIColor whiteColor];
    //设置page数量
    self.totalPagesCount = ^NSInteger(void){
        return imageViews.count;
    };
    //设置每页对应的图片
    __weak AYMCircleScrollView *weakSelf = self;
    self.fetchContentViewAtIndex = ^UIView *(NSInteger pageindex){
        return weakSelf.imageViews[pageindex];
    };
    
    
    
    
}



@end
